package everydayGrade.t4;

import CommonStructure.TreeNode;
import org.junit.jupiter.api.Test;

/**
 * @Author: Siantar
 * @Date: 2023-12-04-16:33
 * @Description: 1.0
 */
public class T1038 {
    int sum = 0;

    public TreeNode bstToGst(TreeNode root) {
        bfs(root);
        return root;
    }

    public void bfs(TreeNode node) {
        if (node == null) return;
        bfs(node.right);
        sum += node.val;
        node.val = sum;
        bfs(node.left);
    }

    @Test
    public void test() {

    }
}
